package com.example.idiom;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.LinkedList;

public class chengyuAdapter extends BaseAdapter {
    private ArrayList<search> mData;
    private Context mcontext;

    public chengyuAdapter(ArrayList<search> mData,Context mcontext){
        this.mData=mData;
        this.mcontext=mcontext;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView= LayoutInflater.from(mcontext).inflate(R.layout.ideas_item,parent,false);
        TextView old_chengyu=convertView.findViewById(R.id.old_chengyu);
        TextView new_chengyu=convertView.findViewById(R.id.new_chengyu);
        old_chengyu.setText(mData.get(position).getOld_chengyu());
        new_chengyu.setText(mData.get(position).getNew_chengyu());
        return convertView;
    }
}
